package 动态规划专项训练.动态规划训练2;

/**394 · 硬币排成线
 * 这种题和leetcode上的石子游戏、硬币排列相似，完了做下
 * @author zx
 * @create 2022-04-19 13:04
 */
public class LintCode394 {
    public boolean firstWillWin(int n) {
        if(n == 0){
            return false;
        }
        if(n <= 2){
            return true;
        }
        boolean[] f = new boolean[n + 1];
        f[0] = false;
        f[1] = f[2] = true;
        for(int i = 3;i <= n;i++){
            f[i] = (f[i - 1]) == false || (f[i - 2] == false);
        }
        return f[n];
    }
}
